You are sneaky!
Quarto is an open-source scientific and technical publishing system that builds on standard markdown with features essential for scientific communication.
Literate programming system in the tradition of Org-Mode, Weave.jl, R Markdown, iPyPublish, Jupyter Book, etc.
---
title: "matplotlib demo"
format:
html:
code-fold: true
jupyter: python3
---
For a demonstration of a line plot on a polar
axis, see @fig-polar.```{python}
#| label: fig-polar
#| fig-cap: "A line plot on a polar axis"
import numpy as np
import matplotlib.pyplot as plt
r = np.arange(0, 2, 0.01)
theta = 2 * np.pi * r
fig, ax = plt.subplots(
subplot_kw = {'projection': 'polar'}
)
ax.plot(theta, r)
ax.set_rticks([0.5, 1, 1.5, 2])
ax.grid(True)
plt.show()
```Can be rendered to dozens of output formats with Quarto (via Pandoc):
| Feature | R Markdown | Quarto |
|---|---|---|
| Basic Formats | ||
| Beamer | ||
| PowerPoint | ||
| HTML Slides | ||
| Advanced Layout |
| Feature | R Markdown | Quarto |
|---|---|---|
| Cross References | ||
| Websites & Blogs | ||
| Books | ||
| Interactivity | Shiny Documents | Quarto Interactive Documents |
| Paged HTML | pagedown | Coming soon! |
| Journal Articles | rticles | Out and more coming! |
| Dashboards | flexdashboard | Coming soon! |
Quarto® is an open-source scientific and technical publishing system built on Pandoc.
.qmd is a plain text fileCode
Plain text workflow (.qmd uses Jupyter kernel to execute cells):
Notebook workflow (defaults to using existing stored computation):
.ipynb?You can keep using them! You get to choose whether to use the stored computation OR re-execute the document from top to bottom.
Quarto can help convert back and forth between plain text .qmd and .ipynb:
quarto convert --help
Usage: quarto convert <input>
Description:
Convert documents to alternate representations.
Convert notebook to markdown: quarto convert doc.ipynb
Convert markdown to notebook: quarto convert doc.qmd
Convert notebook to markdown, write to file: quarto convert doc.ipynb --output doc.qmdBoth RStudio and VSCode with the Quarto extension have rich auto-completion
Quarto also includes native support for Observable JS, a set of enhancements to vanilla JavaScript created by Mike Bostock (also the author of D3)
Converting temperature from ℃ to ℉
Celsius = ℃ and Fahrenheit = ℉.
Quarto uses these to apply common syntax across formats (PDF, HTML, docx, pptx, etc)!
This syntax also applies across code-chunks
```{python}
#| layout-ncol: 2
from plotnine import ggplot, geom_point, geom_boxplot, aes, stat_smooth, facet_wrap, theme
from plotnine.data import mtcars
# plot 1 in column 1
plot1 = (ggplot(mtcars, aes('wt', 'mpg', color='factor(gear)'))
+ geom_point() + stat_smooth(method='lm')
+ facet_wrap('~gear')).draw(show=True)
# plot 2 in column 2
plot2 = (ggplot(mtcars, aes('cyl', 'mpg', color='factor(cyl)'))
+ geom_boxplot()
).draw(show=True)
```One goal of Quarto is to provide a markdown-centric format-agnostic syntax as shown in previous slides.
Quarto projects are directories that provide:
A way to render all or some of the files in a directory with a single command (e.g. quarto render myproject).
A way to share YAML configuration across multiple documents.
The ability to redirect output artifacts to another directory.
The ability to freeze rendered output (i.e. don’t re-execute documents unless they have changed).
Controlled via a _quarto.yml config file.
A _quarto.yml file might look like:
# define as project, set output directory
project:
output-dir: _output
# add global YAML options
toc: true
number-sections: true
bibliography: references.bib
# define the multi-formats that will be rendered
format:
# HTML w/ specific css
html:
css: styles.css
html-math-method: katex
# PDF with specific sizing
pdf:
documentclass: report
margin-left: 30mm
margin-right: 30mm├── _quarto.yml #<- define a Quarto project
├── .venv #<- use a python virtual env
├── exploratory
│ ├── eda.ipynb
│ ├── dplyr-summary.qmd
│ └── plotnine-plots.qmd
├── hyperparameter-tuning
│ ├── grid-define.qmd
│ ├── torch-train.ipynb
│ ├── vetiver-pin.qmd
│ └── vetiver-deploy.py
├── plots
│ ├── density-plot.png
│ ├── roc-curve.png
│ └── accuracy-vs-grid.png
├── _freeze #<- frozen output stored for specific content
│ └── hyperparemeter-tuning
│ └── execute-results
│ └── out.jsonFreeze is generally used when you have either a large number of collaborators or many computational documents created over a longer period of time.
Jupyter natively approaches this as storing the source code, output file, and computation in a single document (.ipynb which is JSON).
Quarto also provides a method but approaches differently:
.qmd or .ipynb).html or .pdf).json and other intermediary filesextensionsDevelopment of Quarto is sponsored by Posit, PBC (formerly known as RStudio, PBC). The same core team works on both Quarto and R Markdown:
Carlos Scheidegger (@cscheid)
Charles Teague (@dragonstyle)
Christophe Dervieux (@cderv)
J.J. Allaire (@jjallaire)
Yihui Xie (@yihui)
Here is the full contributors list. Quarto is open source and we welcome contributions in our github repository as well! https://github.com/quarto-dev/quarto-cli.
Follow @quarto_pub or me @thomas_mock on Twitter/Mastodon to stay up to date!